package JavaDesign.report_1.t_2;

/**
 * @author zouran
 * createDate：2023/9/20  18:18
 */
public class Application {
    public static void main(String[] args) {
        Pillar pillar;
        Geometry bottom;
        double r = 1.0, height = 2.0;
        bottom = null;
        pillar = new Pillar(bottom, height);
        System.out.println("体积：" + pillar.getVolume());

        bottom = new Circle(r);//上转型对象
        pillar = new Pillar(bottom, height);//传入实参对象
        System.out.println("底部为圆形的体积：" + pillar.getVolume());//调用的是Circle里面的getVolume()。

        bottom = new Triangle(2, 2, 3);
        pillar = new Pillar(bottom, height);
        System.out.println("底部为三角形的体积：" + pillar.getVolume());//调用的是Triangle里面的getVolume()。

        bottom = new Rectangle(1, 2);
        pillar = new Pillar(bottom, height);
        System.out.println("底部为长方形的体积：" + pillar.getVolume());//调用的是Rectangle里面的getVolume()
    }
}

